local Utility = require "packages/water_wegame/utility"


--]]
local skills={}

local skill = fk.CreateSkill {
    name = "#jiangjunchouju__skill__weapon",
    attached_equip = "weapon__jiangjunchouju",
}
skill:addEffect("visibility", {})
  Fk:loadTranslationTable{
        ["#jiangjunchouju_equip_skill"] = "将军抽车",
        ["#jiangjunchouju_equip-invoke"] = "你成为伤害牌目标时，使用者可将区域内的一张牌向你移动以令伤害值+1。若为装备牌，则该牌名字与效果改为“将军抽车”。",
  }
local changeskill=function (room, player, isget)
  if isget then
    player.room:handleAddLoseSkills(player,"steam__jiangjunchoujun")
  else
    player.room:handleAddLoseSkills(player,"-steam__jiangjunchoujun")
  end
  room:addPlayerMark(player,"steam__jjcj-turn")
end
skill:addAcquireEffect(function (self, player, is_start)
  changeskill(player.room, player, true)
end)


skill:addLoseEffect(function (self, player, is_start)
  if table.contains(Fk.generals[player.general]:getSkillNameList(), "steam__jiangjunchoujun") and player:hasSkill("steam__jiangjunchoujun") then
    return 
  elseif player.deputyGeneral and table.contains(Fk.generals[player.deputyGeneral]:getSkillNameList(),"steam__jiangjunchoujun") and player:hasSkill("steam__jiangjunchoujun") then
    return 
  end
  if table.find(player:getCardIds("ej"), function (id)
    return Fk:getCardById(id):getMark("steam__jiangjunchoujun")~=0
  end) then
    return 
  end
  changeskill(player.room, player, false)
end)

local smapper = {
   "armor",
   "offensive_horse",
   "defensive_horse",
   "treasure",
}
table.insert(skills, skill)
for _, type in ipairs(smapper) do
  local nskill = fk.CreateSkill {
    name = "#jiangjunchouju__skill__"..type,
    attached_equip = type.."__jiangjunchouju",
  }
  nskill:addEffect("visibility", {})

  nskill:addAcquireEffect(function (self, player, is_start)
    changeskill(player.room, player, true)
  end)
  nskill:addLoseEffect(function (self, player, is_start)
    if table.contains(Fk.generals[player.general]:getSkillNameList(), "steam__jiangjunchoujun") and player:hasSkill("steam__jiangjunchoujun") then
      return 
    elseif player.deputyGeneral and table.contains(Fk.generals[player.deputyGeneral]:getSkillNameList(),"steam__jiangjunchoujun") and player:hasSkill("steam__jiangjunchoujun") then
      return 
    end
    if table.find(player:getCardIds("ej"), function (id)
      return Fk:getCardById(id):getMark("steam__jiangjunchoujun")~=0
    end) then
      room:addPlayerMark(player,"steam__jjcj-turn")
   
      return 
    end
    changeskill(player.room, player, false)
  end)
  table.insert(skills, nskill)
  Fk:loadTranslationTable{
    ["#jiangjunchouju__skill__"..type] = "将军抽车",
  }
end
  
return skills